package com.zj.fx.service.month;

import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zj.fx.common.base.BaseService;
import com.zj.fx.common.support.ConvertUtil;
import com.zj.fx.mapper.month.MonthAuditSubMapper;
import com.zj.fx.model.custom.Tablepar;
import com.zj.fx.model.month.MonthAuditSub;
import com.zj.fx.model.month.MonthAuditSubExample;
import com.zj.fx.model.month.MonthSupplytask;
import com.zj.fx.model.month.MonthSupplytaskExample;
import com.zj.fx.util.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 月度分公司审核提交明细 MonthAuditSubService
 *
 * @author SQL_自动生成
 * @Title: MonthAuditSubService.java 
 * @Package com.zj.fx.service 
 * @email ${email}
 * @date 2023-07-13 10:26:26  
 **/
@Service
public class MonthAuditSubService implements BaseService<MonthAuditSub, MonthAuditSubExample> {
    @Autowired
    private MonthAuditSubMapper monthAuditSubMapper;


    /**
     * 分页查询
     *
     * @param
     * @param
     * @return
     */
    public PageInfo<MonthAuditSub> list(Tablepar tablepar, MonthAuditSub monthAuditSub) {
        MonthAuditSubExample testExample = new MonthAuditSubExample();
        //搜索
        if (StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
            testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
        } else {//大搜索
            testExample.createCriteria().andLikeQuery(monthAuditSub);
        }
        //表格排序
        //if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
        //	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
        //}else{
        //	testExample.setOrderByClause("id ASC");
        //}
        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
        List<MonthAuditSub> list = monthAuditSubMapper.selectByExample(testExample);
        PageInfo<MonthAuditSub> pageInfo = new PageInfo<MonthAuditSub>(list);
        return pageInfo;
    }

    @Override
    public int deleteByPrimaryKey(String ids) {

        List<String> lista = ConvertUtil.toListStrArray(ids);
        MonthAuditSubExample example = new MonthAuditSubExample();
        example.createCriteria().andIdIn(lista);
        return monthAuditSubMapper.deleteByExample(example);


    }


    @Override
    public MonthAuditSub selectByPrimaryKey(String id) {

        return monthAuditSubMapper.selectByPrimaryKey(id);

    }


    @Override
    public int updateByPrimaryKeySelective(MonthAuditSub record) {
        return monthAuditSubMapper.updateByPrimaryKeySelective(record);
    }


    /**
     * 添加
     */
    @Override
    public int insertSelective(MonthAuditSub record) {

        //添加雪花主键id
        record.setId(SnowflakeIdWorker.getUUID());


        return monthAuditSubMapper.insertSelective(record);
    }


    @Override
    public int updateByExampleSelective(MonthAuditSub record, MonthAuditSubExample example) {

        return monthAuditSubMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(MonthAuditSub record, MonthAuditSubExample example) {

        return monthAuditSubMapper.updateByExample(record, example);
    }

    @Override
    public List<MonthAuditSub> selectByExample(MonthAuditSubExample example) {

        return monthAuditSubMapper.selectByExample(example);
    }


    @Override
    public long countByExample(MonthAuditSubExample example) {

        return monthAuditSubMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(MonthAuditSubExample example) {

        return monthAuditSubMapper.deleteByExample(example);
    }


    public PageInfo<MonthAuditSub> list4subcommitplan(String evaluationId, Tablepar tablepar, MonthAuditSub monthAuditSub) {
//        MonthAuditSubExample testExample = new MonthAuditSubExample();
//        //搜索
//        if (StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
//            testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
//        } else {//大搜索
//            testExample.createCriteria().andLikeQuery(monthAuditSub);
//        }
        monthAuditSub.setFkTaskId(evaluationId);
        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
        List<MonthAuditSub> list = monthAuditSubMapper.list4subcommitplan(monthAuditSub);
        PageInfo<MonthAuditSub> pageInfo = new PageInfo<MonthAuditSub>(list);
        return pageInfo;
    }
}
